/*
 * AacHelper.h
 *
 *  Created on: 2015年12月7日
 *      Author: terry
 */

#ifndef AACHELPER_H_
#define AACHELPER_H_

#include "BasicType.h"
#include <string>
#include "TStringUtil.h"


class DLLEXPORT AacHelper
{
public:
	static const size_t ADTS_HEADER_SIZE = 7;

public:
	AacHelper();
	virtual ~AacHelper();

	static int makeConfig(int profile, int freq, int channels, uint8_t* buf, size_t size);

	/*
	@param packetLen 包含ATDS头长度 和 数据长度.
	*/
	static bool makeAdtsHeader(int profile, int freq, int channels, int packetLen, uint8_t* buf, size_t size);

	static int getFreqIndex(int freq);

	static bool isAdts(uint8_t* buf, size_t size);

	static std::string makeConfig(int profile, int freq, int channels)
	{
		uint8_t config[2] = {0};
		makeConfig(profile, freq, channels, config, sizeof(config));
		return comn::StringUtil::format("%02X%02x", config[0], config[1]);
	}

	static bool parse(const uint8_t* buf, size_t size, int& profile, int& channels, int& samplerate);

};



#endif /* AACHELPER_H_ */
